#include "luminanceview.h"

LuminanceView::LuminanceView(QWidget *parent)
    : QWidget{parent}
{
    setUI();
}

void LuminanceView::setUI()
{
    vLayout = new QVBoxLayout();
    vLayout->setContentsMargins(0,0,0,0);
    vLayout->setSpacing(0);
    setLayout(vLayout);

    topWidget = new QWidget();
    label = new QLabel("亮度:",topWidget);
    label->setGeometry(0,0,384,30);
    label->setAlignment(Qt::AlignVCenter);
    label->setObjectName("title");

    numberLabel = new QLabel(topWidget);
    numberLabel->setGeometry(0,62,384,60);
    numberLabel->setAlignment(Qt::AlignVCenter);
    numberLabel->setObjectName("numLabel");

    textlabel = new QLabel("分配亮度值 10% - 100%",topWidget);
    textlabel->setGeometry(0,124,384,15);
    textlabel->setAlignment(Qt::AlignVCenter);
    textlabel->setObjectName("tipsLabel");



    gridLayout = new QGridLayout();
    gridLayout->setSpacing(0);
    gridLayout->setContentsMargins(0, 0, 0, 0);
    QList <QString> list;
    list<<"-"<<"+"<<""<<""<<""<<""<<""<<""<<""<<""<<""<<"";
        for (int i = 0; i < 12; i++){
        pushButton[i] = new QPushButton();
        /* 自动调整按钮的大小 */
        pushButton[i]->setSizePolicy(
            QSizePolicy::Expanding,
            QSizePolicy::Expanding
            );
        if(i==0){
            pushButton[i]->setIcon(QIcon(":/images/na_08.png"));
        }else if(i==1){
            pushButton[i]->setIcon(QIcon(":/images/na_07.png"));
        }
        gridLayout->addWidget(pushButton[i], i/3, i%3);
             pushButton[i]->setObjectName("settingNBtn");
        if(!list[i].isEmpty()){
            pushButton[i]->setObjectName("lumBtn");
        }
        if(i ==2){
            pushButton[i]->setObjectName("lumbBtn");
        }
        if(i == 3 || i==4){
            pushButton[i]->setObjectName("lumNoneBtn");
        }
        if(i<2){
            connect(pushButton[i],&QPushButton::clicked,this,[=](){
                emit clickBtnIndex(i);
            });
        }

    }



    bottomWidget = new QWidget();
    closebtn = new QPushButton("退出",bottomWidget);
    closebtn->setGeometry(0,62,108,62);
    closebtn->setObjectName("baseBtn");
    verifybtn = new QPushButton("确认",bottomWidget);
    verifybtn->setGeometry(108,62,108,62);
    verifybtn->setObjectName("baseBtn");
    autobtn = new QPushButton("手动",bottomWidget);
    autobtn->setGeometry(216,62,108,62);
    autobtn->setObjectName("baseBtn");

    vLayout->addWidget(topWidget,186);
    vLayout->addLayout(gridLayout,248);
    vLayout->addWidget(bottomWidget,124);
}
